<?php

namespace app\index\model;

use think\Db;
use think\Model;

/*
 * 贷款问答
 */
class Question extends Model
{
    //回答状态
    const STATUS_0 = 0;
    const STATUS_1 = 1;

    //是否热门
    const IS_HOT_0 = 0; //否
    const IS_HOT_1 = 1; //是

    /*
     * 贷款问答回复
     */
    public function answer()
    {
        return $this->hasMany('Answer', 'question_id', 'id')
            ->field('id, question_id, reply_type, reply_name, content, add_time');
    }

    /*
     * 回答数量
     */
    public static function getAnswerCount($question_id)
    {
        $count = Db::name('answer')->where('question_id', '=', $question_id)
            ->count();

        return $count;
    }


}